package dao

import (
	"RedWork/util"
	"fmt"
)

func PhoneColorSt(id string) (color []string) {
	strSql := "select color from phone_color where good_id = " + id
	fmt.Println(strSql)
	rows, err := DB.Query(strSql)
	defer rows.Close()
	if err != nil {
		if ok, _, _ := util.ErrHandle(err); ok {
			fmt.Println("mysql err")
		}
	}
	if rows != nil {
		for rows.Next() {
			var data string
			err = rows.Scan(&data)
			if err != nil {
				if ok, _, _ := util.ErrHandle(err); ok {
					fmt.Println("mysql err")
				}
			}
			color = append(color, data)
		}
	}
	fmt.Println(color)
	return
}

func PhoneParameter(id string) (parameter []string) {
	strSql := "select ram_rom from phone_parm where good_id = " + id
	fmt.Println(strSql)
	rows, err := DB.Query(strSql)
	defer rows.Close()
	if err != nil {
		if ok, _, _ := util.ErrHandle(err); ok {
			fmt.Println("mysql err")
		}
	}
	if rows != nil {
		for rows.Next() {
			var data string
			err = rows.Scan(&data)
			if err != nil {
				if ok, _, _ := util.ErrHandle(err); ok {
					fmt.Println("mysql err")
				}
			}
			parameter = append(parameter, data)
		}
	}
	fmt.Println(parameter)
	return
}
